/*! \file
 * \brief Enter a brief description here.
 *
 * Enter a detailed description here. (optional)
 * \author Author (Ivo Wingelaar)
 * \date Date (2011)
 * \version Version (0.0.1)
 * \copyright Copyright (GNU LGPL v3)
 */

#ifndef __LYNX_TEXTURE_HPP_INCLUDED__
#define __LYNX_TEXTURE_HPP_INCLUDED__

#include "LynxColor.hpp"

namespace Lynx
{

enum E_TEXTURE_CREATION_FLAG
{
    ETCF_ALWAYS_16_BIT = 0x00000001,

    ETCF_ALWAYS_32_BIT = 0x00000002,

    ETCF_OPTIMIZED_FOR_QUALITY = 0x00000004,

    ETCF_OPTIMIZED_FOR_SPEED = 0x00000008,

    ETCF_CREATE_MIP_MAPS = 0x00000010,

    ETCF_NO_ALPHA_CHANNEL = 0x00000020,

    ETCF_ALLOW_NON_POWER_2 = 0x00000040,

    ETCF_FORCE_32_BIT_DO_NOT_USE = 0x7fffffff
};

class Texture : public virtual Myth::ReferenceCounter
{
public:
    virtual void* lock(bool readOnly = false, uint32_t mipmapLevel = 0) = 0;

    virtual void unlock() = 0;

    virtual const Myth::Math::Vector2u get_original_size() const = 0;

    virtual const Myth::Math::Vector2u get_size() const = 0;

    virtual E_COLOR_FORMAT get_color_format() const = 0;

    virtual uint32_t get_pitch() const = 0;

    virtual bool has_mip_maps() const = 0;

    virtual bool has_alpha() const = 0;

    virtual void regenerate_mip_map_levels(void* mipmapData = 0) = 0;

    virtual bool is_render_target() const = 0;

    virtual void make_color_key_texture(Color color, bool zeroTexels = false) = 0;

    virtual void make_color_key_texture(Myth::Math::Vector2i colorKeyPixelPos, bool zeroTexels = false) = 0;

    virtual void make_normal_map_texture(float amplitude = 1.0f) = 0;

    virtual const std::string get_name() const = 0;

    virtual void set_name(std::string name) = 0;

protected:
    //! Helper function, helps to get the desired texture creation format from the flags.
    inline E_TEXTURE_CREATION_FLAG get_texture_format_from_flags(uint32_t flags)
    {
        if(flags & ETCF_OPTIMIZED_FOR_SPEED)
            return ETCF_OPTIMIZED_FOR_SPEED;
        if(flags & ETCF_ALWAYS_16_BIT)
            return ETCF_ALWAYS_16_BIT;
        if(flags & ETCF_ALWAYS_32_BIT)
            return ETCF_ALWAYS_32_BIT;
        if(flags & ETCF_OPTIMIZED_FOR_QUALITY)
            return ETCF_OPTIMIZED_FOR_QUALITY;
        return ETCF_OPTIMIZED_FOR_SPEED;
    }
};

} // namespace Lynx

#endif // __LYNX_TEXTURE_HPP_INCLUDED__

